package com.ruoyi.lvlian.domain;


import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.utils.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;

import javax.validation.constraints.NotNull;

/**
 * 支付信息对象 lv_payment_info
 *
 * @author liyuxi
 * @date 2024-05-13
 */
@Data
@ToString

@ApiModel(value = "财务资金-销售收款", description = "财务资金-销售收款")
public class PaymentInfo {
    /** 编号 */
    private String id;

    @ExcelProperty("交易单流水号")
    @ApiModelProperty(value = "交易流水号-一个回单可能对应多个入库")
    private String paymentNum;

//    @ExcelProperty("回单类型")
    @ApiModelProperty(value = "回单类型：1收款回单 2付款回单")
    private String paymentType;

    @ExcelProperty("交易时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "交易时间 yyyy-MM-dd")
    private String payTime;

    @ExcelProperty("检验有效期至")
    @ApiModelProperty(value = "甲方编号-对应主体编号")
    private String buyerCode;

    @ExcelProperty("付款人户名")
    @ApiModelProperty(value = "付款人户名")
    private String buyerName;

    @ExcelProperty("付款人开户行")
    @ApiModelProperty(value = "付款人开户行")
    private String buyerBank;

    @ExcelProperty("付款人开户行账户")
    @ApiModelProperty(value = "付款人账号")
    private String buyerAccno;

    @ExcelProperty("检验有效期至")
    @ApiModelProperty(value = "卖方编号-对应主体编号")
    private String sellerCode;

    @ExcelProperty("收款人户名")
    @ApiModelProperty(value = "收款人户名")
    private String sellerName;

    @ExcelProperty("收款人开户行")
    @ApiModelProperty(value = "收款人开户行")
    private String sellerBank;

    @ExcelProperty("收款人开户行账号")
    @ApiModelProperty(value = "收款人开户行账号")
    private String sellerAccno;

    @ExcelProperty("币种")
    @ApiModelProperty(value = "交易币种")
    private String currency;

    @ExcelProperty("交易单流水金额")
    @ApiModelProperty(value = "交易单流水金额")
    private Double amount;

    /** 大写金额 */
    @ApiModelProperty(value = "大写金额")
    private String amountWords;

    @ExcelProperty("交易渠道")
    @ApiModelProperty(value = "交易渠道")
    private String channel;

    @ExcelProperty("摘要")
    @ApiModelProperty(value = "摘要")
    private String summary;

    @ExcelProperty("回单提供银行")
    @ApiModelProperty(value = "回单提供银行")
    private String bankName;

    /** 剩余金额 */
    @ApiModelProperty(value = "剩余金额")
    private Double remainAmount;

    /** 使用状态 */
    @ApiModelProperty(value = "使用状态")
    private String useSts;

    @ExcelProperty("是否预付款")
    @ApiModelProperty(value = "是否提前付款")
    private String isAdvancePayment;

    /** 是否关联发票 */
    @ApiModelProperty(value = "是否关联发票")
    private String isWithInvoice;

    /** 录入人 */
    @ApiModelProperty(value = "录入人")
    private String createUser;

    /** 录入日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String createDate;

    @ExcelProperty("所属公司编码")
    @ApiModelProperty(value = "")
    private String orgCode;

    /** 用途 */
    @ApiModelProperty(value = "用途")
    private String payPurpose;

    /** 银行回单 */
    @ApiModelProperty(value = "银行回单")
    private String bankImg;

    /** 支付图片 */
    @ApiModelProperty(value = "支付图片")
    private String payImg;


    @ApiModelProperty(value = "分类")
    private String category;

    public String getPayTime() {
        if(StringUtils.isNotEmpty(payTime ) && DateUtils.isValidDateTime(payTime )){
            payTime=   payTime.substring(0,10) ;
        }
        return  payTime;
    }

    public String getId() {
        return id;
    }

    public String getBankImg() {
        if (com.ruoyi.common.core.utils.StringUtils.isNotEmpty(bankImg)) {
            return "https://data.lvlianhengsheng.com/dev-api/file/fileAttachmentInfo/viewImage?key=" + bankImg;
        }
        return bankImg;
    }

    public String getPayImg() {
        if("https://data.lvlianhengsheng.com/dev-api".equalsIgnoreCase( payImg)  || StringUtils.countMatches(  payImg ,"http" )>1    ){
            return null;
        }
        if (com.ruoyi.common.core.utils.StringUtils.isNotEmpty( payImg ) &&  !payImg.contains( "http")) {
            return "https://data.lvlianhengsheng.com/dev-api/file/fileAttachmentInfo/viewImage?key=" +  payImg;
        }
        return payImg;
    }


}
